namespace NHCodeFirst.FluentMapper
{
    using Enums;
    using HbmModel;

    public class DiscriminatorMapper : ColumnMapper<DiscriminatorMapper>
    {
        private readonly Discriminator discriminator;

        internal DiscriminatorMapper(Discriminator discriminator) : base(discriminator.Column)
        {
            this.discriminator = discriminator;
        }

        public DiscriminatorMapper Type(ClrType type)
        {
            discriminator.Type = EnumsToHbmString.GetClrType(type);
            return this;
        }

        public DiscriminatorMapper Type(NHibernateType type)
        {
            discriminator.Type = type.ToString().ToLower();
            return this;
        }

        public DiscriminatorMapper Force(bool value)
        {
            discriminator.Force = value.ToString().ToLower();
            return this;
        }

        public DiscriminatorMapper Formula(string value)
        {
            discriminator.Formula = value;
            return this;
        }

        public DiscriminatorMapper Insert(bool value)
        {
            discriminator.Insert = value.ToString().ToLower();
            return this;
        }
    }
}